package com.core.zyyz.pcmc.controller;


import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.core.zyyz.pcmc.domain.PcmcApplication;
import com.core.zyyz.pcmc.service.PcmcApplicationService;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.core.common.annotation.Log;
import com.core.common.core.controller.BaseController;
import com.core.common.core.domain.AjaxResult;
import com.core.common.enums.BusinessType;
import com.core.common.core.page.TableDataInfo;

/**
 * 应用Controller
 *
 * @author core
 * @date 2024-10-21
 */
@RestController
@RequestMapping("/pcmc/application")
public class PcmcApplicationController extends BaseController {
    @Autowired
    private PcmcApplicationService pcmcApplicationService;

    /**
     * 查询应用列表
     */
    @PreAuthorize("@ss.hasPermi('pcmc:application:list')")
    @GetMapping("/list")
    public TableDataInfo list(PcmcApplication pcmcApplication) {
        startPage();
        List<PcmcApplication> list = pcmcApplicationService.selectPcmcApplicationList(pcmcApplication);
        return getDataTable(list);
    }

    /**
     * 获取应用详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:application:query')")
    @GetMapping(value = "/{appCode}")
    public AjaxResult getInfo(@PathVariable("appCode") String appCode)
    {
        return success(pcmcApplicationService.selectPcmcApplicationByAppCode(appCode));
    }

    /**
     * 新增应用
     */
    @PreAuthorize("@ss.hasPermi('pcmc:application:add')")
    @Log(title = "应用", businessType = BusinessType.INSERT)
    @PostMapping("/insertApplication")
    public AjaxResult add(@RequestBody PcmcApplication pcmcApplication) throws Exception {
        return toAjax(pcmcApplicationService.insertPcmcApplication(pcmcApplication));
    }

    /**
     * 修改应用
     */
    @PreAuthorize("@ss.hasPermi('pcmc:application:edit')")
    @Log(title = "应用", businessType = BusinessType.UPDATE)
    @PostMapping("/updateApplication")
    public AjaxResult edit(@RequestBody PcmcApplication pcmcApplication) {
        return toAjax(pcmcApplicationService.updatePcmcApplication(pcmcApplication));
    }

    /**
     * 删除应用
     */
    @PreAuthorize("@ss.hasPermi('pcmc:application:remove')")
    @Log(title = "应用", businessType = BusinessType.DELETE)
    @PostMapping("/{appCodes}")
    public AjaxResult remove(@PathVariable String[] appCodes) {
        return toAjax(pcmcApplicationService.deletePcmcApplicationByAppCodes(appCodes));
    }
}
